package hng.controller;

import hng.dto.ClientProductDTO;
import hng.model.BannerDO;
import hng.model.NavDO;
import hng.service.ClientService;
import hng.util.JsonData;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.condition.JRE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author 告白
 * @since 2024-06-27
 */
@Slf4j
@RestController
@RequestMapping("/index")
public class ClientController {

    @Autowired(required = false)
    private ClientService clientService;

    /**
     * 获取导航栏
     */
    @GetMapping("/nav-list")
    public JsonData navList() {
        List<NavDO> navDOList = clientService.navList();
        return JsonData.buildSuccess(navDOList);
    }

    /**
     * 获取轮播图
     */
    @GetMapping("/banner-list")
    public JsonData bannerList() {
        List<BannerDO> bannerDOList = clientService.bannerList();
        return JsonData.buildSuccess(bannerDOList);
    }

    /**
     * 获取首页分类下的商品
     */
    @GetMapping("/product-list")
    public JsonData productList() {
        List<ClientProductDTO> productList = clientService.productList();
        return JsonData.buildSuccess(productList);
    }
}
